from django.db import models
from datetime import datetime
from django.utils import timezone


# 基类
class Base(models.Model):
    # 创建事件
    create_time = models.DateTimeField(default=timezone.now, null=True)

    class Meta:
        abstract = True


# 用户表
class User(Base):
    # 用户名
    username = models.CharField(max_length=200)
    # 密码
    password = models.CharField(max_length=200)
    # 头像
    img = models.CharField(max_length=200)
    # 视频
    video = models.CharField(max_length=200, null=True)
    # 类别 0普通用户  1代表管理员  2代表商家
    type = models.IntegerField()

    # 数据库名
    class Meta:
        db_table = "user"


# 幻灯片表
class Pics(Base):
    # 名称
    title = models.CharField(max_length=200)
    # 连接
    link = models.CharField(max_length=200)
    # 图片
    img = models.CharField(max_length=200)

    class Meta:
        db_table = "pics"


# 商品表
class Goods(Base):
    # 商品名称
    name = models.CharField(max_length=200)
    # 商品简介
    desc = models.CharField(max_length=200)
    # 商品规格
    parms = models.CharField(max_length=200)
    # 商品头图
    img = models.CharField(max_length=200, null=True)
    # 演示视频
    video = models.CharField(max_length=200, null=True)
    # 商品价格
    price = models.IntegerField()
    # 关注
    flow = models.IntegerField(default=0, null=True)
    # 分类id
    cate_id = models.IntegerField()

    class Meta:
        db_table = 'goods'


# 商品分类表
class Cate(Base):
    cname = models.CharField(max_length=200)

    class Meta:
        db_table = 'cate'


# 用户评论
class Comment(Base):
    # 评论内容
    content = models.CharField(max_length=200)
    # 谁评论的
    uid = models.IntegerField()
    # 评论的哪个商品
    gid = models.IntegerField()

    class Meta:
        db_table = 'comment'


# 关注表
class UserFlow(Base):
    # 谁关注的
    uid = models.IntegerField()
    # 关注的那个商品
    gid = models.IntegerField()

    class Meta:
        db_table = 'userflow'


